package cn.xixi.start.controller;
import cn.xixi.start.pojo.user.User;
import cn.xixi.start.response.JsonResult;
import cn.xixi.start.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("user")
public class CheckUserController {
  @Autowired private UserService userService;
    @PostMapping("/getUserMessage")
    public JsonResult checkUserName(@RequestBody User user) throws Exception {
//       userService.getMessage(user.getMessage());
        Map<String, Object> responseData = new HashMap<>();
        responseData.put("message", userService.getMessage(user.getMessage()));
//        生成一个90-98的随机数
        int score = (int)(Math.random() * 9 + 90);
        responseData.put("score",score);
        return JsonResult.ok(responseData);
    }

}
